import unittest


class TestDemo(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        print('start')

    @classmethod
    def tearDownClass(cls) -> None:
        print('end')

    # @unittestdemo.skip('test')  #无条件跳过测试, reason为描述跳过的原因
    # @unittestdemo.skipIf(14<2,'test')   #条件为True则跳过
    # @unittestdemo.skipUnless(14<2, 'test')  #条件为False时, 跳过测试
    # @unittestdemo.expectedFailure
    def test_case1(self):
        self.assertEqual(1, 2)

    def test_case2(self):
        print(22222)


if __name__ == '__main__':
    # 方法一
    # 构建测试集对象. 好处: 可以控制执行的测试的条数, 以及顺序
    suite = unittest.TestSuite()
    tests = [TestDemo('test_case1'), TestDemo('test_case2'), ]
    suite.addTests(tests)
    runner = unittest.TextTestRunner(verbosity=2)
    runner.run(suite)
